<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        body{
            background-color: #1b1a1a;
        }
        .stage {
            position: relative;
            width: 500px;
            overflow: hidden;
            left: 25%;
        }

        .stage .mask {
            width: 50%;
            height: 100%;
            /* background: rgba(255, 0, 0, 0.5); */
            background: url("./img/before.jpg");
            background-size: auto 100%;
            position: absolute;
            top: 0;
            left: 0;
        }

        .stage img {
            max-width: 100%;
            display: block;
        }

        .stage input {
            position: absolute;
            left: 0;
            bottom: 0;
            width: 100%;
            margin: 0;
            /* display: none; */
            opacity: 0;
            z-index: 9;
        }

        .progress {
            width: 100%;
            height: 10px;
            background: rgba(255, 255, 255, 0.3);
            position: absolute;
            left: 0;
            bottom: 0;
        }

        .progress span {
            width: 20px;
            height: 10px;
            background: white;
            display: block;
            position: relative;
            top: 0;
            left: 50%;
            margin-left: -10px;
        }
    </style>
</head>

<body>
    <!-- <img src="./img/before.jpg" alt=""> -->

    <div class="stage">
        <div class="mask"></div>
        <img src="./img/after.jpg" alt="" />
        <input type="range" name="" id="" min="0" value="50" max="100" step="1" />
        <div class="progress">
            <span></span>
        </div>
    </div>
    <script src="https://cdn.staticfile.org/jquery/1.12.4/jquery.min.js"></script>

    <script>
        // var stage = document.getElementsByClassName("stage")[0];

        // var mask = stage.getElementsByClassName("mask")[0];
        // var range = stage.getElementsByTagName("input")[0];

        // var dot = stage.getElementsByTagName("span")[0];

        // range.oninput = function () {
        //     // console.log(typeof this.value, this.value);
        //     mask.style.width = this.value + "%";
        //     dot.style.left = this.value + "%";
        // };

        $('input')[0].oninput = function () {
            // console.log(this.value, $(this).val())
            $('.mask').css('width', $(this).val() + '%')
            $('.progress span').css('left', $(this).val() + '%')

        }
    </script>

    <!-- 作业 https://www.17sucai.com/pins/demo-show?id=25562 -->
</body>

</html>